Welcome to Build a DAG Using Airflow. After watching this video, you will be able to: Interpret an Airflow pipeline as a Python
script that defines an Airflow DAG object. List the key components of a DAG definition file. Create tasks by instantiating
operators in your DAG definition file. Set up dependencies amongst tasks. An Apache Airflow DAG is a Python script which
consists of the following logical blocks: Python library imports, DAG argument specification, the DAG definition, or instantiation, Individual task definitions,
which are the nodes of the DAG, and finally, the task pipeline, which
specifies the dependencies between tasks. Let's implement a simple Apache Airflow
pipeline by writing a DAG definition script. We will create a very simple pipeline
called 'simple example DAG dot py', that: prints a greeting, and then prints the current date and time. We will also schedule it to repeat
the process every five seconds. Let’s go through the list of
logical blocks one by one. Begin by importing the Python
libraries you will need for your DAG. Here, start by  importing the DAG
class from the airflow library, then the Bash Operator, which you will
use to create the two print tasks, and the date-time module, which you will need for
specifying several time-related parameters. The next block is for specifying
the default DAG arguments . Notice they are specified as a Python dict, which is just a collection of key-value
pairs, enclosed by curly braces. These are used to specify such things as the owner of the DAG, which is you, and its start date, in this case July 28, 2021. The number of times it should keep trying if
it is failing: here only once if it does fail, and the ‘retry delay’, or the time
to wait between subsequent tries, which in this case is five minutes. The next block is used for instantiating
your workflow as a DAG object. Here you can specify things like the name of your DAG, 'simple example'; a description for your workflow,
for example, 'A simple example DAG'; the default arguments to apply to your DAG, which, in this case, are specified by the 'default
args'  dict you already defined above; and finally, scheduling instructions. In
this case, the DAG will run repeatedly on a schedule interval of five
seconds once it is deployed. Next comes the task definition block. Here we define two tasks, task one and task
two, both of which are  Bash Operators. Their respective IDs are specified
as 'print hello',  and 'print date'. They each call a Bash command, where the first
task  will echo ‘Greetings. The date and time are’, and the second task will print the current
date and time using the Bash command ‘date’. Finally, each task is assigned to the DAG you instantiated in the DAG
definition block above. The final block is where you specify the
dependencies for your workflow, like this. Here,  the double 'greater than' notation specifies that task two is
downstream from task one. This means that task one, which we
named 'print hello', will run first. Once 'print hello' runs successfully,
task two, or 'print date', will run. This completes the creation of your Airflow DAG, and you now have a good idea
of the general pattern. In this video, you learned that: An Airflow pipeline is a Python script
that instantiates an Airflow DAG object. Key components of a DAG definition file
are library imports, DAG arguments, DAG and task definitions, and the
‘task pipeline’ specification. You can specify a schedule interval
in your DAG definition if you want it to run repeatedly by setting
the 'schedule interval' parameter. And finally, tasks are instantiated operators, imported from the Apache
Airflow operators module.